<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <link href="../css/swiper.min.css" rel="stylesheet"/>
    <style>
    .layui-laydate{
      width: 100%!important;
    }.layui-laydate-main{
      width: 100%!important;
    }
    .layui-laydate-content table{
      width: 100%!important;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">班组会</div>
      </div>
      <!--  -->
      <!--  -->
      <div class="x-trtali-box" id="calali" style="margin:1rem"></div>
      <!--  -->
      <div class="x-workforce-tabs swiper-container" style="margin:1rem">
        <div class="swiper-wrapper">
          <div class="swiper-slide x-workforce-items" v-for="(item,index) in formheaderdata" :key="item.id" @click="changetab(index,item.id)" :class="{active:curId==index}">{{item.title}}</div>
        </div>
      </div>
      <!--  -->
      <div class="x-inui-bgbox">

        <template>
          <el-tabs v-model="activeName" @tab-click="handleClick" stretch="true">
            <el-tab-pane label="添加计划" name="first">
              <!--  -->
              <div class="x-pro-list">
                <div class="x-pro-top x-inc-num">工作总结</div>
                <div class="x-for-border" v-for="item in workall" :key="item.key">
                  <div class="x-pro-row">
                    <div class="x-pro-label">项目名称:</div>
                    <div class="x-pro-input">
                      {{item.title}}
                    </div>
                  </div>
                  <div class="x-pro-row x-pro-rowblock">
                    <div class="x-pro-label">内容:</div>
                    <div class="x-pro-input">
                      <el-input placeholder="请输入内容" v-model="item.content" type="textarea" :rows="4"></el-input>
                    </div>
                  </div>
                </div>
              </div>
              <!--  -->
              <div class="x-pro-list">
                <div class="x-pro-top x-inc-num">发布公告</div>
                <div class="x-pro-row">
                  <div class="x-pro-input">
                    <el-input placeholder="请输入内容" v-model="sendask" type="textarea" :rows="4"></el-input>
                  </div>
                </div>
              </div>
              <!--  -->
              <div class="x-pro-gobtn" @click="isok">提交</div>
            </el-tab-pane>
            <el-tab-pane label="检查总结" name="second">
              <!--  -->
              <div class="x-pro-list">
                <div class="x-for-border" v-for="item in checkdata" :key="item.key">
                  <div class="x-pro-row">
                    <div class="x-pro-label">项目名称:</div>
                    <div class="x-pro-input">
                      {{item.title}}
                    </div>
                  </div>
                  <div class="x-pro-row">
                    <div class="x-pro-label">检查结果:</div>
                    <div class="x-pro-input">
                      <el-button type="primary" v-if="item.is_ok=='0'" @click="workok(item.id,item.title)" size="mini">点击确认</el-button>
                      <div v-if="item.is_ok=='1'" size="mini" class="x-text-g">已完成</div>
                      <div v-if="item.is_ok=='2'" size="mini" class="x-text-r">未完成</div>
                    </div>
                  </div>
                  <div class="x-pro-row">
                    <div class="x-pro-label">记录要点:</div>
                    <div class="x-pro-input">
                      <el-input placeholder="请输入" v-model="item.content"></el-input>
                    </div>
                  </div>
                </div>
              </div>
              <!--  -->
              <div class="x-pro-gobtn" @click="isoktwo">提交</div>
            </el-tab-pane>
          </el-tabs>
        </template>
      </div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
  <script type="text/javascript" src="../script/swiper.min.js"></script>
  <script type="text/javascript" src="../script/laydate/laydate.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          thmonth:'',
          formheaderdata:'',
          curId:0,
          activeName: 'first',
          tableData:[],
          checkdata:'',
          workall:'',
          sendask:'',
          edittoast:false,
          textvalue:'',
          input4:'',
          tabsid:'',
          istype:'0',
        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        laydate.render({
          elem: '#calali',
          position: 'static',
          btns:['now'],
          format:'yyyyMMdd',
          // theme:'#058142',
          change:function(value,date){
            console.log(value);
            that.thmonth = value;
            if(that.istype=='0'){
              that.getdata()
            }else if(that.istype=='1'){
              that.getdatatwo()
            }
          }
        });
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var day = date.getDate()
        if(month<10){
          month = '' + 0 + month;
        }
        if(day<10){
          day = '' + 0 + day;
        }
        var toMonth = '' + year +  month +  day;
        that.thmonth = toMonth;
        that.getdata()

      },
      methods: {
        //检查结果
        workok:function(id,name){
          var that = this;
          api.actionSheet({
              title: '请确认“'+ name + '”的检查结果',
              cancelTitle: '取消',
              buttons: ['已完成', '未完成']
          }, function(ret, err) {
              var index = ret.buttonIndex;
              if(index=='1'){
                that.settake(id,index)
              }else if(index=='2'){
                that.settake(id,index)
              }

          });
        },
        //检查结果 提交
        settake:function(id,index){
          let that=this;
          api.ajax({
            url:baseurl+'api/team/updateState',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                cateid:that.tabsid,
                date:that.thmonth,
                checkid:id,
                type:index
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                if(that.istype=='0'){
                  that.getdata()
                }else if(that.istype=='1'){
                  that.getdatatwo()
                }


              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        isok:function(){
          var that = this;
          console.log(JSON.stringify(that.workall));
          api.ajax({
            url:baseurl+'api/team/setSummary',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.thmonth,
                cateid:that.tabsid,
                content_json:that.workall,
                notice:that.sendask
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.confirm({
                    title: '提交成功',
                    msg: '',
                    buttons: ['继续编辑', '返回']
                }, function(ret, err) {
                    var index = ret.buttonIndex;
                    if(index=='1'){

                    }else{
                      api.closeWin({});

                    }
                });

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        isoktwo:function(){
          var that = this;
          console.log(that.thmonth);
          console.log(that.tabsid);
          console.log(JSON.stringify(that.checkdata));
          api.ajax({
            url:baseurl+'api/team/setCheck',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.thmonth,
                cateid:that.tabsid,
                content_json:that.checkdata
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.confirm({
                    title: '提交成功',
                    msg: '',
                    buttons: ['继续编辑', '返回']
                }, function(ret, err) {
                    var index = ret.buttonIndex;
                    if(index=='1'){

                    }else{
                      api.closeWin({});

                    }
                });

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        getdata:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/team/getSummary',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.thmonth,
                cateid:that.tabsid
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                  that.formheaderdata = ret.data.cate;
                  that.workall = ret.data.list;
                  that.sendask = ret.data.notice.content;
                  that.tabsid = ret.data.cate[0].id;
                  var nunum;
                  if(that.formheaderdata.length<3){
                    nunum = 2;
                  }else{
                    nunum = 3;
                  }
                  that.$nextTick(function(){
                    var mySwiper = new Swiper('.swiper-container',{
                      freeMode: true,
                      loop:false,//设置 active slide 居中后，会有左右留白现象，添加此会让未尾的导航补齐前后空白
                      slideToClickedSlide: true,//设置为true则点击slide会过渡到这个slide。
                      slidesPerView: nunum,
                      centeredSlides: false,//设定为true时，active slide会居中，而不是默认状态下的居左。
                      spaceBetween: 10,//slide之间设置距离
                      slidesOffsetBefore: 0,//设定slide与左边框的预设偏移量
                      slidesOffsetAfter: 0,//设定slide与右边框的预设偏移量

                    });

                  });
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //检查
        getdatatwo:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/team/getCheck',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.thmonth,
                cateid:that.tabsid
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                  that.checkdata = ret.data.list;
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //切换选项卡 表格数据
        changetab:function(index,id){
          var that = this;
          that.curId = index;
          that.tabsid = id;
          if(that.istype=='0'){
            that.getdata()
          }else if(that.istype=='1'){
            that.getdatatwo()
          }
        },
        //选项卡
        handleClick(tab, event) {
          let id = event.target.getAttribute('id').split('-');
          let whitetab = id.join('').substring(3,9);
          let that = this;
          if(whitetab=='first'){//
            that.istype = '0';
            that.getdata()
          }else if(whitetab=='second'){//
            that.istype = '1';
            that.getdatatwo()
          }
        },
      }
    })
	}


	</script>
</body>
</html>
